package ligapiwna.servlets.beerManagement;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ligapiwna.model.dto.BeerDTO;
import ligapiwna.model.services.BeerService;
import ligapiwna.model.services.impl.mock.BeerServiceMock;

/**
 * Servlet implementation class AddBeer
 */
public class AddBeer extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private BeerService beerService;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddBeer() {
        super();
    }

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	public void init(ServletConfig config) throws ServletException {
		beerService = new BeerServiceMock();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String name = request.getParameter("beerName");
		String description = request.getParameter("beerDescription");
		
		if(name!= null && !name.equals("") )
				beerService.addBeer(name);

		response.sendRedirect("BeerLister");
	}


}
